<template>
  <div class="block">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="company_name" label="公司名称" width="220" />
      <el-table-column label="所在城市" width="120">
        <template #default="{ row }">
          {{JSON.parse(row.work_location).province + ' ' + JSON.parse(row.work_location).city}}
        </template>
      </el-table-column>
      <el-table-column prop="station" label="入职岗位" width="150" />
      <el-table-column prop="entry_date" label="入职时间" width="90" />
      <el-table-column prop="salary" label="薪资" width="100" />
      <el-table-column prop="offer" label="入职通知书" width="100" >
        <template #default="scope">
          <el-button v-if="scope.row.offer!==''" type="primary" @click="showOffer(scope.row.offer)">预览</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="is_entry" label="学员选择" width="90" >
        <template #default="scope">{{ ENTRY_TYPE[scope.row.is_entry]!==undefined ? ENTRY_TYPE[scope.row.is_entry] : '其他'}}</template>
      </el-table-column>
      <el-table-column prop="remark" label="备注" width="160" />
    </el-table>
  </div>
</template>
<script setup>

import {ENTRY_TYPE} from "@/dict/dict-employment";
import {ElMessage} from "element-plus";
import {getEmploymentByStudentIdAPI} from "@/network/employment/employment";
import EventBus from "@/plugins/event-bus";
import {ref} from "vue";

const studentId = ref()
const tableData = ref([])


EventBus.on("show-student-employmentDetail-info-event",(eventData)=>{
  studentId.value=eventData.studentId
  showEmploymentInfo()
})

const showEmploymentInfo = () => {
  getEmploymentByStudentIdAPI(studentId.value).then(res => {
    if (res.data.code !== 0) {
      ElMessage.error(res.data.message)
    }
    else {
      tableData.value = res.data.data
    }

  })
}

const showOffer = (offer) => {
  let url = process.env.VUE_APP_BASE_FILE_URL + offer
  window.open(url, '_blank');
}
</script>

<style scoped lang="less">

</style>